	<script language="javascript">
	function showtheohinhthuc(id,d)
	{
		//document.dstintuc.value_radio.value=d.value;
		showdataday(id,'admin/showtheohinhthuc.php?hinhthuc=' + d.value);
	}
</script>
	<p>DANH SÁCH TIN RAO VẶT</p>
	<label class="stylelitle">Hình thức:</label>&nbsp;
				<select name="select" onchange="showtheohinhthuc('id_hinhthuc',this)">
				<?php
					$where='';
					$ma="all";
					$ten="Tất cả";
					if(isset($_GET['hinhthuc']))
					{
						$ma=$_GET['hinhthuc'];
						if($ma!="all")
						{
							$t=$knoi->queryCsdl("select tenht from hinhthuc where maht='$ma'");
							$t1=mysql_fetch_array($t);
							$ten=$t1['tenht'];
							$where=$where."where maht!=$ma";
						}							
					}
				 ?>
                  <option selected="selected" value="<?php echo $ma; ?>"><?php echo $ten; ?></option>
                  <?php
				  $kq=$knoi->queryCsdl("select * from hinhthuc".$where);
				while($n=mysql_fetch_array($kq))
				{
			?>
                  <option value="<?php echo $n['maht']; ?>"><?php echo $n['tenht']; ?></option>
                  <?php
				}
			?>
                </select>
	</label>
	<div id="id_hinhthuc">
	<?php
		$kq=$knoi->queryCsdl("select matin from tinraovat a,khachhang b,tinhthanhpho c,hinhthuc d,loainhadat e where a.makh=b.makh and a.mattp=c.mattp and a.maht=d.maht and a.maloai=e.maloai");
		$c=mysql_num_rows($kq);
		if(mysql_num_rows($kq)<1)
			echo "<br><label class='stylelitle'>Hiện tại chưa có tin rao vặt nào!</label>";
		else
		{
		$tongdong=mysql_num_rows($kq);
		$dong_trang=9;
		$sotrang=ceil($tongdong/$dong_trang);
		
		$limit="0,".$dong_trang;
		if(isset($_GET['page']))
		{
			$t=$_GET['page'];
			$ar=explode(":",$t);
			$limit=$ar[1];
		}
		if($sotrang==1)
			$kq=$knoi->queryCsdl("select matin,tieude,tentinhtp,tenht,ngaydang,ngayhethan,tenkh,tenloai from tinraovat a,khachhang b,tinhthanhpho c,hinhthuc d,loainhadat e where a.makh=b.makh and a.mattp=c.mattp and a.maht=d.maht and a.maloai=e.maloai order by tentinhtp,tenht,ngaydang desc");
		else
			$kq=$knoi->queryCsdl("select matin,tieude,tentinhtp,tenht,ngaydang,ngayhethan,tenkh,tenloai from tinraovat a,khachhang b,tinhthanhpho c,hinhthuc d,loainhadat e where a.makh=b.makh and a.mattp=c.mattp and a.maht=d.maht and a.maloai=e.maloai order by tentinhtp,tenht,ngaydang desc limit $limit");
				?>
		<table align="center" style="border:solid #FFFFFF; background-color:#F5F5F5">
			<tr class="stylelitle" style="text-align:center; background-color:#CCFFFF"><td>Stt</td><td>Tỉnh/Tp</td><td>Loại nhà đất</td><td>Tiêu đề</td><td>Ngày đăng</td><td>Ngày hết hạn</td><td>Khách hàng</td><td>Chi tiết</td><td>Xóa</td></tr>
		<?php
			$i=1;
			if(isset($_GET['i']))
				$i=$_GET['i'] + 1;
			while($n=mysql_fetch_array($kq))
			{
				if($i%2==0)
					$color='#FFFFCC';
				else
					$color='#FFFFFF';
		?>
			<tr class="classtr" style="text-align:left; background-color:<?php echo $color; ?>;"><td style="text-align:right"><?php echo $i; ?>&nbsp;</td>
			<td>&nbsp;<?php echo $n['tentinhtp']; ?></td><td>&nbsp;<?php echo $n['tenloai']; ?></td><td>&nbsp;<?php echo $n['tieude']; ?></td><td style="text-align:center"><?php echo $knoi->formatDate($n['ngaydang']); ?></td><td style="text-align:center"><?php echo $knoi->formatDate($n['ngayhethan']); ?></td><td>&nbsp;<?php echo $n['tenkh']; ?></td><td style="text-align:center"><a  href="home_admin.php?module=thongtinraovat&matin=<?php echo $n['matin']; ?>"><img src="images/chitiet.png" border="0" title="Chi tiết tin rao vặt" /></a></td><td style="text-align:center"><a href="home_admin.php?module=xoa&field=matin&table=tinraovat&value=<?php echo $n['matin']; ?>"><img src="images/Sign-Error-icon1.png" border="0" title="Xóa tin rao vật" /></a></td></tr>
		<?php
			$i++;
			}
		?>
		</table>
	<?php
		
		if($sotrang>1)
			{
		 	if($ar[0]!=1 && isset($_GET['page']))
				$color='#0033CC';
			else
				$color='#000000';
			$start="1:0,".$dong_trang;
			?>
			<div> Pages &nbsp;
			<?php
				echo "<a href='home_admin.php?module=danhsachtinraovat&hinhthuc=$ma&page=$start' style='color:$color'>1</a>";
			for($i=2;$i<=$sotrang;$i++)
			{
				if($ar[0]==$i)
					$color='#000000';
				else
					$color='#0033CC';
				$p=($i-1)*$dong_trang;
				$page=$i.":".$p.",".$dong_trang;
				echo "&nbsp;<a href='home_admin.php?module=danhsachtinraovat&hinhthuc=$ma&page=$page&i=$p' style='color:$color'>$i</a>";	
			}
		}
		}
		if($c<1)
			echo "<br>";
	?>
	<br /><br><label style="text-align:center" class="button"><a class="menulink" href="home_admin.php?module=tinraovat"><img src="images/add.png" border="0">&nbsp;Thêm tin mới</a></label>
</div>